const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    entry: path.join(__dirname, 'src', 'app.js'),
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'js/[name].bundle.js'
    },
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.js$/,
                include: path.join(__dirname,'src'),
                exclude: path.resolve(__dirname,'node_modules'),
                loader: "babel-loader",
                query: {
                    presets: ['env']
                }
            },
            {
                test: /\.html$/,
                loader: 'html-loader',
                options: {
                //    minimize: true
                }
            },
            {
                test: /\.ejs$/,
                loader: 'ejs-loader'
            },
            {
                test: /\.css$/,
                include: path.join(__dirname,'src'),
                loader: [
                    'style-loader',
                    {
                        loader:'css-loader',
                        options: { importLoaders: 1}
                    },
                    "postcss-loader"
                ]
            },
            {
                test: /\.styl(us)?$/,
                loader : [
                    'style-loader',
                    'css-loader',
                    "postcss-loader",
                    "stylus-loader"
                ]
            },
            {
                test: /\.(png|jpg|gif|svg)$/i,
                loader: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 10000,
                            name: 'assets/[name]-[hash:5].[ext]'
                        }
                    },
                    {
                        loader: 'image-webpack-loader',
                        options: {
                       //     bypassOnDebug: true,
                        }
                    }
                ]
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
            filename: 'index.html',
            template: 'index.html',
            inject: 'body',
            minify: {
                removeComments: true,
                removeTagWhitespace: true,
                collapseWhitespace: true
            },
        })
    ]

};